package com.mc.lp.database.entity.helper;

import org.apache.commons.lang.StringUtils;

import com.mc.lp.database.entity.AttachmentEntity;
import com.mc.lp.database.entity.MicroCampusEntity;
import com.mc.lp.database.entity.type.RecordType;
import com.mc.lp.shared.vo.StudentProfileVO;
/*
 * @author aphanda
 * @date Dec 24, 2014
 * @time 3:34:28 PM
 */

public class MicroCampusHelper implements IEntityHelper<MicroCampusEntity, StudentProfileVO>{

	@Override
	public StudentProfileVO getVO(MicroCampusEntity entity) {
		// TODO Auto-generated method stub
		StudentProfileVO vo = new StudentProfileVO();
		vo.setAddressLine1(entity.getAddress().getLine1()+entity.getAddress().getLine2());
		vo.setAddressLine2(entity.getAddress().getCity()+", "+entity.getAddress().getStateProvinceCounty()+", "+entity.getAddress().getCountry() +" - "+entity.getAddress().getZipOrPostcode());
		vo.setEmail(entity.getPrimaryEmail());
		vo.setContactNo(StringUtils.join(entity.getContacts(),','));
		vo.setDob("21-January-2004"); //AP 14th Feb
		vo.setEntityId(entity.getId());
		vo.setFatherName(entity.getMotherLastName());
		vo.setFirstName(entity.getFirstName());
		vo.setLastName(entity.getLastName());
		vo.setMotherName(entity.getMotherFirstName());
		vo.setRegistrationNumber(String.valueOf(entity.getRegistration().getId()));
		
		if (null != entity.getAttachments() && !entity.getAttachments().isEmpty()) {
			for (AttachmentEntity attach : entity.getAttachments()) {
				if (attach.getRecordTypeId() == RecordType.PROFILE_PIC.getId()) {
					vo.setPhotoId(attach.getId());
				}
			}
		}
		
		vo.setSchoolId(1L); //AP 14th Feb set school id and school details in vo
		vo.setSchoolAddress(String.valueOf(entity.getSchoolBranch()));
		vo.setSchoolContact("011-22335566");
		vo.setSchoolName("Dav School");
		
		return vo;
	}

	@Override
	public MicroCampusEntity getEntity(StudentProfileVO vo) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void setEntity(StudentProfileVO vo, MicroCampusEntity entity) {
		// TODO Auto-generated method stub
		
	}
}
